package com.zzh.ssi.frame.jdbc.support;

import org.logicalcobwebs.cglib.proxy.Factory;
import org.logicalcobwebs.proxool.WrappedConnection;
import org.springframework.jdbc.support.nativejdbc.NativeJdbcExtractorAdapter;

import java.sql.Connection;
import java.sql.SQLException;

/**
 * Date: 2011-8-13
 * Time: 13:01:51
 */
public class ProxoolNativeJdbcExtractor extends NativeJdbcExtractorAdapter {

    protected Connection doGetNativeConnection(Connection con) throws SQLException {
        if (con instanceof Factory) {
            Factory factory = (Factory) con;
            WrappedConnection wc = (WrappedConnection) factory.getCallback(0);
            return wc.getProxyConnection().getConnection();
        }
        return con;
    }
}
